<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<title>Insert title here</title>
<script type="text/javascript" src="${initParam.root }jquery-1.9.1.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		//생일이 숫자인지 실시간체크하기
		$("#birthday").keyup(function() {
			var birthNum = $("#birthday").val();
			if (isNaN(birthNum)) {
				$("#checkNumSpace").html("생일은 숫자로만 입력해주세요");
			}else if(birthNum.length!=8){
				$("#checkNumSpace").html("생일은 8자리로 입력해주세요");	
			} else {
				$("#checkNumSpace").html("");
			}
		});//생일이 적었을 때 

		//회원가입 폼 빈칸체크
		$("#updateForm").submit(function() {
			if ($("form [name=id]").val() == "") {
				alert("id를 입력해 주세요");
				return false;
			} else if ($("form [name=password]").val() == "") {
				alert("비밀번호를 입력해 주세요");
				return false;
			} else if ($("form [name=name]").val() == "") {
				alert("이름을 입력해 주세요");
				return false;
			} else if ($("form [name=address]").val() == "") {
				alert("주소를 입력해 주세요");
				return false;
			} else if ($("form [name=birthday]").val() == "") {
				alert("생일을 입력해 주세요");
				return false;
			} else if ($("form [name=gender]").is(':checked') == false) {
				alert("성별을 선택해 주세요");
				return false;
			} else if ($("form [name=cellphone]").val() == "") {
				alert("비밀번호를 입력해 주세요");
				return false;
			} else if ($("form [name=email]").val() == "") {
				alert("e-mail 주소를 입력해 주세요");
				return false;
			} else if ($("#checkNumSpace").text() != "") {
				alert("생일은 숫자로만 입력해주세요");
				return false;
			} else if ($("#checkIdDuplSpace").text() != "") {
				alert("아이디가 중복되었습니다");
				return false;
			}

		});//수정 버튼 클릭시
	});
</script>
</head>
<body>
	<c:choose>
		<c:when test="${sessionScope.userInfo==null}">
			<script type="text/javascript">
				alert("로그인 후에 이용가능한 서비스입니다");
				location.href = "${initParam.root}member.do?command=home";
			</script>
		</c:when>
		<c:otherwise>
			<h2>회원정보수정</h2>
			<br>
			<form id="updateForm" action="${initParam.root }member.do"
				method="post">
				<input type="hidden" name="command" value="update"> id: <input
					type="text" name="id" value="${sessionScope.userInfo.id }"
					readonly="readonly"><br> password: <input
					type="password" name="password"><br> 이름: <input
					type="text" name="name" value="${requestScope.info.name }"><br>
				주소: <input type="text" name="address"
					value="${requestScope.info.address }"><br> 생일( 8자리로
				입력해주세요. 예시 - 19900908): <input type="text" name="birthday"
					id="birthday" value="${requestScope.info.birthday }"> <span
					id="checkNumSpace"></span><br>

				<c:if test="${requestScope.info.gender == 'male'}">
			성별:<input type="radio" name="gender" value="male" checked="checked">남
	 		<input type="radio" name="gender" value="female">여<br>
				</c:if>
				<c:if test="${requestScope.info.gender == 'female'}">
			성별:<input type="radio" name="gender" value="male">남
	 		<input type="radio" name="gender" value="female" checked="checked">여<br>
				</c:if>

				전화번호: <input type="text" name="cellphone"
					value="${requestScope.info.cellphone }"><br> e-mail: <input
					type="text" name="email" value="${requestScope.info.email }"><br>
				<input type="submit" value="회원정보수정">
			</form>
		</c:otherwise>
	</c:choose>

</body>
</html>